@extends('admin.master')

@section('top')
	<span class="top-title pull-left">统计</span>
@endsection

@section('content')
<div class="partition mb10"><span>登录信息</span></div>
<ul class="home-user-info">
	<li>登录者：<b>{{ $user->name }}</b>，用户名：<b>{{ $user->username }}</b>，所属用户组：<b>{{ $user->group->name }}</b></li>
	<li>这是您第 <b>{{ $user->loginnum }}</b> 次登录 ，登录IP：<b>{{ $request->ip() }}</b></li>
</ul>
@if ($user->group->level > 7)
	<div class="partition mb10"><span>用户数量</span></div>
	<div class="user-count-block">
		<div class="table-block">
			<table class="table table-bordered">
				<thead>
					<tr class="active">
						<td class="text-center">区域</td>
						<td class="text-center">总监</td>
						<td width="100">商务</td>
						<td width="100">经理</td>
						<td width="120" class="text-center">人数</td>
					</tr>
				</thead>
			@foreach($departments as $value)
				<tr>
					<td class="text-center text-size-16"><strong>{{ $value['name'] }}</strong></td>
					<td class="text-center text-size-14"><strong>{{ $managers->get($value['manager'])->name or '' }}</strong></td>
					<td colspan="3" class="table-inner-wrap">
						<table class="table table-bordered table-inner">
		  				@if (isset($value['children']))
			  				@foreach($value['children'] as $children)
			  				<tr>
			  					<td width="99.5">{{ $children['name'] }}</td>
			  					<td width="100" class="text-success">{{ $managers->get($children['manager'])->name or '' }}</td>
			  					<td class="text-center">{{ $departmentCount->get($children['id']) }}</td>
			  				</tr>
			  				@endforeach
		  				@endif
						</table>
					</td>
				</tr>
			@endforeach
			</table>
		</div>
	</div>
	<div class="partition mb10"><span>订单统计</span></div>
	<table class="table table-bordered len500">
		<td>订单总量： <b class="text-success">{{ $ordercount->sum() }}</b></td>
		@foreach(config('system.order_status') as $key=>$value)
			<td>{{ $value }}： <b class="text-success">{{ $ordercount->get($key, 0) }}</b></td>
		@endforeach
	</table>
@endif
@endsection